
import * as Vuex from 'vuex'

export default Vuex.createStore({
  state: {
    nodeMap: new Map(),
    isEdit: null,
    loginUser: JSON.parse(localStorage.getItem('loginUser'))|| {},
    selectedNode: {},
    selectFormItem: null,
    design: {},
    roles: localStorage.getItem('roles') || '',
    lang: localStorage.getItem('lang') || '',
    formItem: [],
    menus: localStorage.getItem('menus') || '',
    selectIndex:localStorage.getItem('selectIndex') ||null, //企业门户上的选择
    menuList:JSON.parse(localStorage.getItem('menuList'))|| {},
  },
  mutations: {
    selectedNode(state, val) {
      state.selectedNode = val
    },
    loadForm(state, val) {
      state.design = val
    },
    setIsEdit(state, val) {
      state.isEdit = val
    },
    // 添加登录人信息
    loginUserAdd(state, val) {
      state.loginUser = val
    },
    // 添加登录人角色信息
    rolesAdd(state, val) {
      state.roles = val
    },
    // 选择器选择的数据村本地
    formItemAdd(state, val) {
      state.formItem.push(val)
    },
    formItemClear(state, val) {
      state.formItem = []
    },
    // 添加登录人角色信息
    menusAdd(state, val) {
      state.roles = val
    },
    // 企业门户的操作
    selectIndexAdd(state, val) {
      state.selectIndex = val
    },
    // 添加登录人信息
    menuSelectAdd(state, val) {
      state.menuList = val
    },

  },
  getters: {},
  actions: {},
  modules: {},
})
